package mgt.pages

class RateLimitStrategyCreatePage extends geb.Page {
    static url = "/rateLimitStrategy/create"

    static content = {
        apiDefinitionSelect(wait: true) { $("#apiDefinitions") }

        nameField(wait: true) { $("#name") }
        apiLimitField(wait: true) { $("#apiLimit") }
        userLimitField(wait: true) { $("#userLimit") }
        descriptionField(wait: true) { $("#description") }

        createButton(to: RateLimitStrategyShowPage) { $(".save") }
    }

    RateLimitStrategyShowPage createRateLimitStrategy(Long apiDefinitionId, String name, Long apiLimit, Long userLimit, String description) {
        apiDefinitionSelect.value(apiDefinitionId)

        nameField.value(name)
        apiLimitField.value(apiLimit)
        userLimitField.value(userLimit)
        descriptionField.value(description)

        createButton.click()

        return browser.page
    }
}